package com.poetic.order.function;

import com.poetic.order.domain.OrderEvent;
import com.poetic.order.domain.OrderResult;
import org.apache.flink.cep.PatternTimeoutFunction;

import java.util.List;
import java.util.Map;

/**
 * <pre>
 *  自定义超时事件序列处理函数
 * Created by lianghuikun on 2020-09-16.
 * </pre>
 *
 * @author lianghuikun
 */
public class OrderTimeOutSelect implements PatternTimeoutFunction<OrderEvent, OrderResult> {
    @Override
    public OrderResult timeout(Map<String, List<OrderEvent>> pattern, long timeoutTimestamp) throws Exception {

        Long timeoutOrderId = pattern.get("begin").iterator().next().getOrderId();
        return new OrderResult(timeoutOrderId, "timeout");
    }
}
